#include<stdio.h>
int isYuiShu(int n,int m){
	int count=0;
	for(int v=1;v<=m;v++){
		if(n%v==0){
			count++;
		}
	}
	if(count%2==1){
		return 1;
	}
	else{
		return 0;
	}
}
int main(){
	int n;
	int m;
	scanf("%d %d",&n,&m);
	int count=0;
	for(int u=1;u<=n;u++){
		if(isYuiShu(u,m)==1){
			printf("%4d",u);
			count++;
			if(count%5==0){
				printf("\n");
			}
		}
	}
}
